package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.ApplicablePlatformEnum;
import com.frogs.system.util.GoodsEvaluateEnum;
import com.frogs.system.util.OpenPlatformEnum;
import com.frogs.system.web.exception.RequestIllegalException;
import com.frogs.system.web.api.request.Request;

/**
 * 商品评价批量请求参数类
 *
 * @author lijian
 * @version 2014年5月6日 - 上午9:44:05
 */
public class GoodsEvaluateBatchMergeRequest extends Request {

	/**
	 * 账号ID
	 */
	private int userId;
	/**
	 * 是否药师认证评价
	 */
	private int isPharmacistEvaluate;
	/**
	 * 评价json数组<br>
	 * 例：<br>
	 * [{<br>
	 * &nbsp;&nbsp;		originalGoodsId:原始商品ID 必传(int),<br>
	 * &nbsp;&nbsp;		goodsId:商品ID 必传(int),<br>
	 * &nbsp;&nbsp;		score:商品评分 (int),<br>
	 * &nbsp;&nbsp;		content:评价内容 (String),<br>
	 * &nbsp;&nbsp;		tagIds:标签IDs,用逗号间隔(String),<br>
	 * &nbsp;&nbsp;		tag:标签,用逗号间隔(String),<br>
	 * &nbsp;&nbsp;		buyTime:购买时间，格式yyyy-MM-dd(String)<br>
	 * &nbsp;&nbsp;		orderId:评价对应的订单，选填(String)<br>
	 * }]<br>
	 */
	private String evaluates;
	/**
	 * 适用范围
	 */
	private int applicablePlatformId;
	
	private int openPlatformId;
	
	/** */
	public GoodsEvaluateBatchMergeRequest() {
		
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.isPharmacistEvaluate = requestInfo.getIntParameter(ApiUrlParamEnum.isPharmacistEvaluate.getParamName(), GoodsEvaluateEnum.IS_PHARMACIST_EVALUATE_NO.getId());
		this.applicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.applicablePlatformId.getParamName(), ApplicablePlatformEnum.WEB.getId());
		this.evaluates = requestInfo.getParameter(ApiUrlParamEnum.evaluates.getParamName(), "");
		this.openPlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.openPlatformId.getParamName(), OpenPlatformEnum.WECHAT_HDC.getId());
		if ( userId < 1 ) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if ( StringUtil.isEmpty(evaluates) ) {
			throw new RequestIllegalException("error evaluates: " + evaluates);
		}
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getIsPharmacistEvaluate() {
		return isPharmacistEvaluate;
	}

	public void setIsPharmacistEvaluate(int isPharmacistEvaluate) {
		this.isPharmacistEvaluate = isPharmacistEvaluate;
	}

	public int getApplicablePlatformId() {
		return applicablePlatformId;
	}

	public void setApplicablePlatformId(int applicablePlatformId) {
		this.applicablePlatformId = applicablePlatformId;
	}

	public String getEvaluates() {
		return evaluates;
	}

	public void setEvaluates(String evaluates) {
		this.evaluates = evaluates;
	}

	public int getOpenPlatformId() {
		return openPlatformId;
	}

	public void setOpenPlatformId(int openPlatformId) {
		this.openPlatformId = openPlatformId;
	}

}
